﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Troschuetz.Random;
using HurSimLib;

namespace WinUI
{
    public class Simulation
    {
        #region Privates
        DateTime m_startDate;

        public DateTime StartDate
        {
            get { return m_startDate; }
            set { m_startDate = value; }
        }
        DateTime m_endDate;

        public DateTime EndDate
        {
            get { return m_endDate; }
            set { m_endDate = value; }
        }
        Generator m_generator;

        public Generator Generator
        {
            get { return m_generator; }
            set { m_generator = value; }
        }
        Distribution m_distribution;

        public Distribution Distribution
        {
            get { return m_distribution; }
            set { m_distribution = value; }
        }

        HurObjectGenerator m_hurObjectGenerator;

        public HurObjectGenerator HurObjectGenerator
        {
            get { return m_hurObjectGenerator; }
            set { m_hurObjectGenerator = value; }
        }

        private HurProcessBase m_process;

        public HurProcessBase Process
        {
            get { return m_process; }
            set { m_process = value; }
        }

        #endregion
        public Simulation()
        {
            m_hurObjectGenerator = new HurObjectGenerator();
        }
        private void _init()
        {
            m_hurObjectGenerator.GenerationStart = m_startDate;
            m_hurObjectGenerator.GenerationEnd = m_endDate;
            m_hurObjectGenerator.GeneratorDistribution = m_distribution;
            m_hurObjectGenerator.NextProcess = m_process;
        }
        public string Exec()
        {
            _init();
            StringBuilder sb = new StringBuilder();
            sb.AppendLine("---- ----#####---- ----\n");
            sb.AppendLine(string.Format("Giren Nesne Sayısı : {0}\n", this.m_process.Entryqueue.Count));
            sb.AppendLine("---- ---- ---- ----\n");
            foreach (var item in this.m_process.Entryqueue)
            {
                sb.AppendLine("---- ---- ---- ----");
                sb.Append(string.Format("TotalServiceTime-> Hour: {0}, Minutes: {1}, Seconds: {2}, Milliseconds:{3} \n  TotalWaitingTime-> Hour: {4}, Minutes: {5}, Seconds: {6}, milliseconds: {7}\n", item.TotalServiceTime.Hour, item.TotalServiceTime.Minute, item.TotalServiceTime.Second, item.TotalWaitingTime.Millisecond, item.TotalWaitingTime.Hour, item.TotalWaitingTime.Minute, item.TotalWaitingTime.Second, item.TotalWaitingTime.Millisecond));

            }
            return sb.ToString();
        }
    }
}
